/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package xmarti.vacaxm.client.maintenance.animal;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComboBox;
import xmarti.vacaxm.action.ImplMaintenance;
import xmarti.vacaxm.action.ImplPerson;
import xmarti.vacaxm.beans.connect.Destination;
import xmarti.vacaxm.beans.connect.Origin;
import xmarti.vacaxm.beans.maintenance.AnimalFilter;
import xmarti.vacaxm.beans.maintenance.Bull;
import xmarti.vacaxm.beans.maintenance.Cow;
import xmarti.vacaxm.exception.ExceptionHibernateVacaxm;
import xmarti.vacaxm.utils.TDSLanguageUtils;
import xmarti.vacaxm.utils.ValidarText;

/**
 *
 * @author xmarti
 */
public class JDFilterAnimal extends javax.swing.JDialog {
    private ImplMaintenance aMaintenance=null; 
    private ImplPerson aPerson=null;
    private AnimalFilter animalFilter=null;
    public JDFilterAnimal(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();        
        this.animalFilter= new AnimalFilter(); 
        this.aMaintenance=new ImplMaintenance(); 
        this.aPerson=new ImplPerson(); 
        this.jTextAgeStart.setDocument(new ValidarText(3,true));
        this.jTextAgeEnd.setDocument(new ValidarText(3,true));
        this.setTitle(TDSLanguageUtils.getMessage("jdFilterAnimal.caption"));    
        initObjects();
    }
    
    private void saveData(){        
        if(this.jCheckBoxAge.isSelected()){
            if(this.jTextAgeStart.getText().length()>0)this.animalFilter.setAgeStart( Integer.parseInt(this.jTextAgeStart.getText()));
            else this.animalFilter.setAgeStart(0);
            if(this.jTextAgeEnd.getText().length()>0)this.animalFilter.setAgeEnd( Integer.parseInt(this.jTextAgeEnd.getText()));
            else this.animalFilter.setAgeEnd(1000);
            this.animalFilter.setAgeFilter(true);
        }else{         
            this.animalFilter.setAgeFilter(false);
        }              
        if(this.jCheckBoxDateHigh.isSelected()){
            this.animalFilter.setDateHighStart(this.jDateChooserDateHighStart.getDate());
            this.animalFilter.setDateHighEnd(this.jDateChooserDateHighEnd.getDate());
            this.animalFilter.setDateHighFilter(true);
        }else{
            this.animalFilter.setDateHighFilter(false);            
        }
        if(this.jCheckBoxDateLow.isSelected()){
            this.animalFilter.setDateLowStart(this.jDateChooserDateLowStart.getDate());
            this.animalFilter.setDateLowEnd(this.jDateChooserDateLowEnd.getDate());
            this.animalFilter.setDateLowFilter(true);            
        }else{
            this.animalFilter.setDateLowFilter(false);            
        }        
        this.animalFilter.setFather((Bull) this.jComboFather.getSelectedItem());
        this.animalFilter.setMother((Cow)this.jComboMother.getSelectedItem());
        this.animalFilter.setOrigin((Origin)this.jComboOrigin.getSelectedItem());
        this.animalFilter.setDestination((Destination)this.jComboDestination.getSelectedItem());
    }
    private void chargeCows(){                 
        jComboMother.removeAllItems();
        try {                    
            jComboMother.addItem( new Cow()); 
            for(Cow c:aMaintenance.getCows())jComboMother.addItem(c);                  
        } catch (ExceptionHibernateVacaxm ex) {
           //todo
            Logger.getLogger(JPAnimalData.class.getName()).log(Level.SEVERE, null, ex);
        }        
    }
    private void chargeBulls(){                
        this.jComboFather.removeAllItems();
        try {                    
           this.jComboFather.addItem(new Bull(" - "));
           for(Bull c:aMaintenance.getBulls())
           jComboFather.addItem(c);                            
        } catch (ExceptionHibernateVacaxm ex) {
            //todo
            Logger.getLogger(JPAnimalData.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }
    private void chargeOrigins(){                
        jComboOrigin.removeAllItems();        
        jComboOrigin.addItem (new Origin());
        for(Origin c:aPerson.getOrigin())jComboOrigin.addItem(c);                            
    }   
    private void chargeDestinations(){               
        jComboDestination.removeAllItems();
        jComboDestination.addItem(new Destination());                    
        for(Destination c:aPerson.getDestinations())jComboDestination.addItem(c);                            
        
    }     
    private void jComboChange(java.awt.event.ActionEvent evt) {                                             
        JComboBox jCombo = (JComboBox) evt.getSource();
        if (jCombo.getSelectedIndex()==0) jCombo.setSelectedIndex(-1);
    }   

    public AnimalFilter getAnimalFilter() {
        return animalFilter;
    }

    public void setAnimalFilter(AnimalFilter animalFilter) {
        this.animalFilter = animalFilter;
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jComboMother = new javax.swing.JComboBox();
        jLabelMother = new javax.swing.JLabel();
        jComboFather = new javax.swing.JComboBox();
        jLabelFather = new javax.swing.JLabel();
        jComboOrigin = new javax.swing.JComboBox();
        jLabelOrigin = new javax.swing.JLabel();
        jComboDestination = new javax.swing.JComboBox();
        jLabelDestination = new javax.swing.JLabel();
        jButtonCancelFilter = new javax.swing.JButton();
        jButtonApplyFilter1 = new javax.swing.JButton();
        jPanelDateLow = new javax.swing.JPanel();
        jLabelBeetwen3 = new javax.swing.JLabel();
        jLabelAnd3 = new javax.swing.JLabel();
        jCheckBoxDateLow = new javax.swing.JCheckBox();
        jDateChooserDateLowEnd = new JCalendarXM.JTextCalendarXM();
        jDateChooserDateLowStart = new JCalendarXM.JTextCalendarXM();
        jPanelAge = new javax.swing.JPanel();
        jLabelBeetwen1 = new javax.swing.JLabel();
        jTextAgeStart = new javax.swing.JTextField();
        jLabelAnd1 = new javax.swing.JLabel();
        jTextAgeEnd = new javax.swing.JTextField();
        jCheckBoxAge = new javax.swing.JCheckBox();
        jPanelDateHigh = new javax.swing.JPanel();
        jLabelBeetwen2 = new javax.swing.JLabel();
        jLabelAnd2 = new javax.swing.JLabel();
        jCheckBoxDateHigh = new javax.swing.JCheckBox();
        jDateChooserDateHighStart = new JCalendarXM.JTextCalendarXM();
        jDateChooserDateHighEnd = new JCalendarXM.JTextCalendarXM();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(430, 510));
        setModal(true);
        setResizable(false);

        jPanel1.setPreferredSize(new java.awt.Dimension(430, 350));

        jComboMother.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboMother.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboMotherActionPerformed(evt);
            }
        });

        jLabelMother.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabelMother.setForeground(java.awt.SystemColor.activeCaption);
        jLabelMother.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabelMother.setText(TDSLanguageUtils.getMessage("jdFilterAnimal.label.mother.caption"));

        jComboFather.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboFatherActionPerformed(evt);
            }
        });

        jLabelFather.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabelFather.setForeground(java.awt.SystemColor.activeCaption);
        jLabelFather.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabelFather.setText(TDSLanguageUtils.getMessage("jdFilterAnimal.label.father.caption"));

        jComboOrigin.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboOrigin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboOriginActionPerformed(evt);
            }
        });

        jLabelOrigin.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabelOrigin.setForeground(java.awt.SystemColor.activeCaption);
        jLabelOrigin.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabelOrigin.setText(TDSLanguageUtils.getMessage("jdFilterAnimal.label.origin.caption"));

        jComboDestination.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboDestination.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboDestinationActionPerformed(evt);
            }
        });

        jLabelDestination.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabelDestination.setForeground(java.awt.SystemColor.activeCaption);
        jLabelDestination.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabelDestination.setText(TDSLanguageUtils.getMessage("jdFilterAnimal.label.destination.caption"));

        jButtonCancelFilter.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jButtonCancelFilter.setText(TDSLanguageUtils.getMessage("jdFilterAnimal.jButtonCancel.caption"));
        jButtonCancelFilter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCancelFilterActionPerformed(evt);
            }
        });

        jButtonApplyFilter1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jButtonApplyFilter1.setText(TDSLanguageUtils.getMessage("jdFilterAnimal.jButtonFilter.caption"));
        jButtonApplyFilter1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonApplyFilter1ActionPerformed(evt);
            }
        });

        jPanelDateLow.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), TDSLanguageUtils.getMessage("jdFilterAnimal.jPanelDateLow.caption"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), java.awt.SystemColor.activeCaption)); // NOI18N

        jLabelBeetwen3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabelBeetwen3.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelBeetwen3.setText(TDSLanguageUtils.getMessage("jdFilterAnimal.label.beetwen.caption"));

        jLabelAnd3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabelAnd3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelAnd3.setText(TDSLanguageUtils.getMessage("jdFilterAnimal.label.and.caption"));

        jCheckBoxDateLow.setText(TDSLanguageUtils.getMessage("jdFilterAnimal.jCheckBoxDateLow.caption"));
        jCheckBoxDateLow.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxDateLowActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelDateLowLayout = new javax.swing.GroupLayout(jPanelDateLow);
        jPanelDateLow.setLayout(jPanelDateLowLayout);
        jPanelDateLowLayout.setHorizontalGroup(
            jPanelDateLowLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelDateLowLayout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addComponent(jLabelBeetwen3, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jDateChooserDateLowStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabelAnd3, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jDateChooserDateLowEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(jPanelDateLowLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jCheckBoxDateLow, javax.swing.GroupLayout.PREFERRED_SIZE, 323, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        jPanelDateLowLayout.setVerticalGroup(
            jPanelDateLowLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelDateLowLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanelDateLowLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanelDateLowLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jLabelAnd3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabelBeetwen3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jDateChooserDateLowEnd, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jDateChooserDateLowStart, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jCheckBoxDateLow, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jPanelAge.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), TDSLanguageUtils.getMessage("jdFilterAnimal.jPanelAge.caption"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), java.awt.SystemColor.activeCaption)); // NOI18N

        jLabelBeetwen1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabelBeetwen1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelBeetwen1.setText(TDSLanguageUtils.getMessage("jdFilterAnimal.label.beetwen.caption"));

        jTextAgeStart.setMinimumSize(new java.awt.Dimension(40, 25));
        jTextAgeStart.setPreferredSize(new java.awt.Dimension(40, 25));

        jLabelAnd1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabelAnd1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelAnd1.setText(TDSLanguageUtils.getMessage("jdFilterAnimal.label.and.caption"));

        jTextAgeEnd.setMinimumSize(new java.awt.Dimension(40, 25));
        jTextAgeEnd.setPreferredSize(new java.awt.Dimension(40, 25));

        jCheckBoxAge.setText(TDSLanguageUtils.getMessage("jdFilterAnimal.jCheckBoxAge.caption"));
        jCheckBoxAge.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxAgeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelAgeLayout = new javax.swing.GroupLayout(jPanelAge);
        jPanelAge.setLayout(jPanelAgeLayout);
        jPanelAgeLayout.setHorizontalGroup(
            jPanelAgeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jCheckBoxAge, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelAgeLayout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addComponent(jLabelBeetwen1, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextAgeStart, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelAnd1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextAgeEnd, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        jPanelAgeLayout.setVerticalGroup(
            jPanelAgeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelAgeLayout.createSequentialGroup()
                .addGap(4, 4, 4)
                .addGroup(jPanelAgeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabelBeetwen1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanelAgeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jTextAgeStart, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabelAnd1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jTextAgeEnd, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 5, Short.MAX_VALUE)
                .addComponent(jCheckBoxAge))
        );

        jPanelDateHigh.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), TDSLanguageUtils.getMessage("jdFilterAnimal.jPanelDateHigh.caption"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), java.awt.SystemColor.activeCaption)); // NOI18N
        jPanelDateHigh.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabelBeetwen2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabelBeetwen2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelBeetwen2.setText(TDSLanguageUtils.getMessage("jdFilterAnimal.label.beetwen.caption"));
        jPanelDateHigh.add(jLabelBeetwen2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 28, 38, -1));

        jLabelAnd2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabelAnd2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelAnd2.setText(TDSLanguageUtils.getMessage("jdFilterAnimal.label.and.caption"));
        jPanelDateHigh.add(jLabelAnd2, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 30, 27, -1));

        jCheckBoxDateHigh.setText(TDSLanguageUtils.getMessage("jdFilterAnimal.jCheckBoxDateHigh.caption"));
        jCheckBoxDateHigh.setOpaque(false);
        jCheckBoxDateHigh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxDateHighActionPerformed(evt);
            }
        });
        jPanelDateHigh.add(jCheckBoxDateHigh, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 50, 339, -1));
        jPanelDateHigh.add(jDateChooserDateHighStart, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 20, 130, 25));
        jPanelDateHigh.add(jDateChooserDateHighEnd, new org.netbeans.lib.awtextra.AbsoluteConstraints(222, 20, 140, 25));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabelFather, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(20, 20, 20)
                        .addComponent(jLabelMother, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jComboFather, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(50, 50, 50)
                        .addComponent(jComboMother, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabelOrigin, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(20, 20, 20)
                        .addComponent(jLabelDestination, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jComboOrigin, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(50, 50, 50)
                        .addComponent(jComboDestination, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanelAge, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(jPanelDateHigh, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(jButtonApplyFilter1, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButtonCancelFilter, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGap(10, 10, 10)
                            .addComponent(jPanelDateLow, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelFather)
                    .addComponent(jLabelMother))
                .addGap(5, 5, 5)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jComboFather, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboMother, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(5, 5, 5)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelOrigin)
                    .addComponent(jLabelDestination))
                .addGap(5, 5, 5)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jComboOrigin, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboDestination, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanelAge, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanelDateHigh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanelDateLow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(25, 25, 25)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonApplyFilter1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonCancelFilter, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(14, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 396, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 1, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 457, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    private void initObjects(){
        chargeBulls();
        chargeCows();
        chargeOrigins();
        chargeDestinations();
        jCheckBoxAgeActionPerformed(null);
        jCheckBoxDateHighActionPerformed(null);
        jCheckBoxDateLowActionPerformed(null);
        
    }
            
    private void jButtonCancelFilterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelFilterActionPerformed
        this.animalFilter= new AnimalFilter(); 
        this.dispose();
               
    }//GEN-LAST:event_jButtonCancelFilterActionPerformed

    private void jButtonApplyFilter1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonApplyFilter1ActionPerformed
        saveData();
        this.dispose();
        
    }//GEN-LAST:event_jButtonApplyFilter1ActionPerformed

    private void jComboFatherActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboFatherActionPerformed
        jComboChange(evt);
    }//GEN-LAST:event_jComboFatherActionPerformed

    private void jComboMotherActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboMotherActionPerformed
        jComboChange(evt);
    }//GEN-LAST:event_jComboMotherActionPerformed

    private void jComboOriginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboOriginActionPerformed
        jComboChange(evt);
    }//GEN-LAST:event_jComboOriginActionPerformed

    private void jComboDestinationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboDestinationActionPerformed
        jComboChange(evt);
    }//GEN-LAST:event_jComboDestinationActionPerformed

    private void jCheckBoxAgeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxAgeActionPerformed
        this.jPanelAge.setEnabled(this.jCheckBoxAge.isSelected());  
        this.jTextAgeStart.setEnabled(this.jCheckBoxAge.isSelected());
        this.jTextAgeEnd.setEnabled(this.jCheckBoxAge.isSelected());
        this.jLabelAnd1.setEnabled(this.jCheckBoxAge.isSelected());
        this.jLabelBeetwen1.setEnabled(this.jCheckBoxAge.isSelected());
    }//GEN-LAST:event_jCheckBoxAgeActionPerformed

    private void jCheckBoxDateHighActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxDateHighActionPerformed
        this.jPanelDateHigh.setEnabled(this.jCheckBoxDateHigh.isSelected());
        this.jDateChooserDateHighStart.setEnabled(this.jCheckBoxDateHigh.isSelected());
        this.jDateChooserDateHighEnd.setEnabled(this.jCheckBoxDateHigh.isSelected());
        this.jLabelAnd2.setEnabled(this.jCheckBoxDateHigh.isSelected());
        this.jLabelBeetwen2.setEnabled(this.jCheckBoxDateHigh.isSelected());
    }//GEN-LAST:event_jCheckBoxDateHighActionPerformed

    private void jCheckBoxDateLowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxDateLowActionPerformed
        this.jPanelDateLow.setEnabled(this.jCheckBoxDateLow.isSelected());
        this.jDateChooserDateLowStart.setEnabled(this.jCheckBoxDateLow.isSelected());
        this.jDateChooserDateLowEnd.setEnabled(this.jCheckBoxDateLow.isSelected());
        this.jLabelAnd3.setEnabled(this.jCheckBoxDateLow.isSelected());
        this.jLabelBeetwen3.setEnabled(this.jCheckBoxDateLow.isSelected());
    }//GEN-LAST:event_jCheckBoxDateLowActionPerformed

    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonApplyFilter1;
    private javax.swing.JButton jButtonCancelFilter;
    private javax.swing.JCheckBox jCheckBoxAge;
    private javax.swing.JCheckBox jCheckBoxDateHigh;
    private javax.swing.JCheckBox jCheckBoxDateLow;
    private javax.swing.JComboBox jComboDestination;
    private javax.swing.JComboBox jComboFather;
    private javax.swing.JComboBox jComboMother;
    private javax.swing.JComboBox jComboOrigin;
    private JCalendarXM.JTextCalendarXM jDateChooserDateHighEnd;
    private JCalendarXM.JTextCalendarXM jDateChooserDateHighStart;
    private JCalendarXM.JTextCalendarXM jDateChooserDateLowEnd;
    private JCalendarXM.JTextCalendarXM jDateChooserDateLowStart;
    private javax.swing.JLabel jLabelAnd1;
    private javax.swing.JLabel jLabelAnd2;
    private javax.swing.JLabel jLabelAnd3;
    private javax.swing.JLabel jLabelBeetwen1;
    private javax.swing.JLabel jLabelBeetwen2;
    private javax.swing.JLabel jLabelBeetwen3;
    private javax.swing.JLabel jLabelDestination;
    private javax.swing.JLabel jLabelFather;
    private javax.swing.JLabel jLabelMother;
    private javax.swing.JLabel jLabelOrigin;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanelAge;
    private javax.swing.JPanel jPanelDateHigh;
    private javax.swing.JPanel jPanelDateLow;
    private javax.swing.JTextField jTextAgeEnd;
    private javax.swing.JTextField jTextAgeStart;
    // End of variables declaration//GEN-END:variables
}
